/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package carrello;

import javax.ejb.EJB;

/**
 *
 * @author v
 */
public class Main {
    @EJB
    private static Cart cart;
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Main m = new Main();
        m.doTest();
    }

    public void doTest() {
        try {
            cart.initialize("Merlo Vincenzo", "12");
            cart.addBook("miao");
            cart.addBook("bau");
            cart.addBook("cracra");

            for (String book: cart.getContents())
                System.out.println("book: " + book);

            String bookToBeRemove = (String) cart.getContents().toArray()[1];
            System.out.println("Remove book: " + bookToBeRemove);
            cart.removeBook(bookToBeRemove);

            for (String book: cart.getContents())
                System.out.println("book: " + book);

            cart.remove();

            System.exit(0);

        }catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

}
